package com.yztc.ui.home;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yztc.helper.RecyclerViewAdapterHelper;
import com.yztc.okbuy.R;

import org.w3c.dom.Text;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by My on 2016/12/19.
 */

public class HomeAdapter extends RecyclerViewAdapterHelper<HomeBean.ResultsBean> {

    public HomeAdapter(Context context, List<HomeBean.ResultsBean> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.fragment_home_list, parent, false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        if(holder instanceof  ViewHolder){
//            ((ViewHolder) holder).imageView.setImageResource(R.mipmap.ic_launcher);
            ((ViewHolder) holder).textBlake.setText(list.get(position).getContents());
            ((ViewHolder) holder).textRed.setText(list.get(position).getTips());
            Glide.with(context).load(list.get(position).getAdvert_pic()).into(((ViewHolder) holder).imageView);
        }
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView textBlake;
        private TextView textRed;

       public ViewHolder(View view) {
           super(view);
           imageView = (ImageView) view.findViewById(R.id.image_home);
           textBlake = (TextView) view.findViewById(R.id.text_home_black);
           textRed = (TextView) view.findViewById(R.id.text_home_red);
        }
    }
}
